package com.wenya.counter.data.db;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.wenya.counter.data.bean.ScriptureBean;

import java.util.List;

@Dao
public interface ScriptureDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(ScriptureBean scriptureBean);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(List<ScriptureBean> scriptureBeans);

    @Query("UPDATE ScriptureBean SET times = :times WHERE name = :name")
    int update(String name, int times);

    @Query("SELECT * FROM ScriptureBean ORDER BY divisor")
    List<ScriptureBean> getAll();

    @Query("UPDATE ScriptureBean SET times = 0 WHERE name in (:names)")
    int reset(List<String> names);

    @Query("DELETE FROM ScriptureBean WHERE name in (:names)")
    int delete(List<String> names);

    @Query("SELECT count(1) FROM ScriptureBean")
    int selectCount();
}
